<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- 兼容性 -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
	<title>计划编制-关键节点计划列表</title> <script src="/scripts/boot.js"></script>
	<style>
html, body {
	margin: 0;
	padding: 0;
	border: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
}

body {
	background: #ffffff !important;
	padding: 20px;
}
</style>
</head>
<body>
	<div class="title-list mb-20">
		<span class="title-listbg"></span><span>月度工作计划</span>
	</div>
	<div id="qForm" class="mini-toolbar1"
		style="border-bottom: 0; padding: 0px;">

		<table id=""></table>
		<table style="width: 100%;">
			<tr>
				<td style="width: 100%;">
					<div class="mb-20">
						<span class="search-title search-ml20">节点名称</span><input id="nodeNames" name="nodeNames" class="mini-textbox search-200px">
						<span class="search-title search-ml60">选择年月</span><div id="yearItem"></div>
						<a class="add-botton search-ml60" onclick="list.search()">查询</a>
						<a class="resetting-btn search-ml20" onclick="list.reset()">重置</a>

					</div>
				</td>
			</tr>
		</table>
	</div>
	<div class="container">
		<div class="mini-clearfix mb-10">
			<div class="mini-col-6 mini-col-sm-6">
				<a class="plan-btn mR-20" onclick="list.addOrEdit('new')"><span class="add-bg"></span>新增计划申请</a>
				<a class="plan-btn mR-20" onclick="list.addOrEditChange('edit')"><span class="add-bg"></span>新增计划调整</a>
				<a class="stamp-export mR-20"  onclick="list.print()"><span class="stamp-bg"></span><span class="span-line">打印</span></a>
				<a class="bill-export mR-20"  onclick="list.exportExcel()"><span class="bill-bg"></span><span class="span-line">导出</span></a>
			</div>
		</div>
	</div>
	<div class="mini-fit">
		<div id="datagrid1" class="mini-datagrid"
			style="width: 100%; height: 100%;"
			url="/monthlyPlanExecution/listByPage" sizeList="[5,10,20,50]"
			pageSize="20" idField="user_id" multiSelect="false" showEmptyText="true" emptyText="暂无数据" alwaysShowEmptyText="true">
			<div property="columns">
				<div type="checkcolumn" headerAlign="center" align="center"></div>
				<div type="indexcolumn" width="35" headerAlign="center" align="center">编号</div>
				<div field="planName" width="120" headerAlign="center" allowSort="false">计划名称</div>
				<!--<div field="businessName" width="120" headerAlign="center" allowSort="false">业务板块</div>-->
				<!--<div field="planTypeName" width="120" headerAlign="center" allowSort="false">计划类型</div>-->
				<div field="nodeName" width="120" headerAlign="center" allowSort="false">节点名称</div>
				<!--<div field="nodePropertyName" width="120" headerAlign="center" allowSort="false">节点性质</div>-->
				<!--<div field="completeStandard" width="120" headerAlign="center" allowSort="false">完成标准</div>-->
				<div field="state" width="120" headerAlign="center" align="center" allowSort="false">状态</div>
				<div field="rate" width="120" headerAlign="center" align="center" allowSort="false">进度</div>
				<div field="beginDate" width="200" headerAlign="center" align="center" allowSort="false">计划起止时间</div>
				<div field="completeDate" width="120" headerAlign="center" align="center" allowSort="false">完成时间</div>
				<!--<div field="postName" width="120" headerAlign="center" align="center" allowSort="false">负责人</div>-->
                <!--<div field="postId" width="120" headerAlign="center" align="center" allowSort="false">调整类型</div>-->
				<!--<div field="postId" width="120" headerAlign="center" align="center" allowSort="false">延期到的时间</div>-->
				<!--<div field="remark" width="120" headerAlign="center" align="center" allowSort="false">备注</div>-->
				<div field="aduitState" width="120" headerAlign="center" align="center" allowSort="false">成果确认状态</div>
				<div name="action" width="240" headerAlign="center" align="center">操作</div>
			</div>
		</div>
	</div>
	<script type="text/javascript">
	//1未开始、2进行中 、3、有风险4、失控、5、已完成 6、延期完成
	var Genders = [{ id: 1, text: '未开始' },
		{ id: 2, text: '进行中'},
		{ id: 3, text: '有风险'},
		{ id: 4, text: '失控'},
		{ id: 5, text: '已完成'},
		{ id: 6, text: '延期完成'},
		{ id: 7, text: '逾期'},
		{ id: 8, text: '节点暂停'},
		{ id: 9, text: '节点取消'}];
	var aduitGenders = [{ id: 1, text: '审批中' },
		{ id: 2, text: '审批通过'},
		{ id: 3, text: '审批失败'}];

    var list = {
        //页面初始化
        init: function() {
            mini.parse();
            common.changeYears();
            mini.get("datagrid1").load();
            if(list.getURLParameter("state")){
            	list.SetData({"state":list.getURLParameter("state")});
            }
            mini.get("datagrid1").on("drawcell", function (e) {
                var column = e.column;
                if (column.name == "action") {/* 
                	var fruit;
                	if(e.row.supervise==1){
                		fruit='<a class="check-botton" href="javascript:list.completeReport()">成果填报</a>';
                	}else{
                		fruit="";  ---  '+(fruit?"btn-bd":"")+'
                	} */
                	var record='<a class="revise-botton " href="javascript:list.recordInfo()">进度填报</a>';
                	if(e.row.rate==100){
                		record="";/* 
                		fruit=""; */
                		if(e.row.fruitType==1){
                			record='<a class="del-botton " href="javascript:list.dataPrint()">资料套打</a>';
                		}
                	}
                	if(e.row.aduitState==1){
                		record="";
                	}else if(e.row.aduitState==3){
                		record='<a class="revise-botton " href="javascript:list.recordInfo()">进度填报</a>';
                	}else if(e.row.state==9){
                		record="";
                	}
                	
                    e.cellHtml = /* fruit+ */record+'<a class="check-botton '+(/* fruit|| */record?"btn-bd":"")+'" href="javascript:list.recordList()">填报记录</a>'+
                     '<a class="check-botton btn-bd" href="javascript:list.view()">计划详情</a>';
                }
                if(column.field=="beginDate"){
                    var dateText = "";
                    if(e.row.beginDate&&e.row.endDate){
                        dateText="至"
                    }
                    e.cellHtml = e.row.beginDate.substring(0,10)+dateText+e.row.endDate.substring(0,10);
                }
                if(column.field=="rate"){
                    e.cellHtml = e.row.rate+'%';
                }
                if(column.field=="aduitState"){
                    if(e.row.aduitState=="0"){
                        e.cellHtml = '';
                    }else if(e.row.aduitState=="1"){
                        e.cellHtml = '审批中';
                    }else if(e.row.aduitState=="2"){
                        e.cellHtml = '通过';
                    }else if(e.row.aduitState=="3"){
                        e.cellHtml = '未通过';
                    }
                }
                if(column.field=="state"){
                	if(e.row.state=="8"){
                        e.cellHtml = '<span>节点暂停</span>';
                    }else if(e.row.state=="9"){
                        e.cellHtml = '<span>节点取消</span>';
                    }else{
                    	if(e.row.riskState=="1"){
                    		if(e.row.state=="7"){
                                e.cellHtml = '<span class="span-orange">逾期</span>';
                            }else{
                                e.cellHtml = '<span class="span-yellow">有风险</span>';
                            }
                    	}else if(e.row.riskState=="2"){
                            e.cellHtml = '<span class="span-red">失控</span>';
                    	}else{
                    		if(e.row.state=="1"){
                                e.cellHtml = '<span>未开始</span>';
                            }else if(e.row.state=="2"){
                                e.cellHtml = '<span class="span-green">进行中</span>';
                            }else if(e.row.state=="5"){
                                e.cellHtml = '<span>已完成</span>';
                            }else if(e.row.state=="6"){
                                e.cellHtml = '<span>延期完成</span>';
                            }else if(e.row.state=="7"){
                                e.cellHtml = '<span class="span-orange">逾期</span>';
                            }
                    	}
                    }
                }
            })
        },
        getURLParameter: function (name) { 
        	return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
        },
        onGenderRenderer: function (e) {
            for (var i = 0, l = Genders.length; i < l; i++) {
                var g = Genders[i];
                if (g.id == e.value) return g.text;
            }
            return "";
        },
        //    新增或编辑
        addOrEdit: function (opt) {
            mini.open({
                url: "/program/monthlyPlan/new.html",
                title: (opt=="edit"?"编辑":"新增")+"节点计划申请", width: 1100, height: 700,
                onload: function () {
                    if(opt=="edit"){
                        var row = mini.get("datagrid1").getSelected();
                    }else{
                        var data = {"state":opt};
                    }
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    mini.get("datagrid1").reload();
                }
            });
        },
        addOrEditChange:function(opt){ 
        	var row = mini.get("datagrid1").getSelected();
	        if(row){
	        	if(row.state==5||row.state==6){
	            	mini.alert("已完成的计划节点不能进行调整");
	        	}else{
		            mini.open({
		                url: "/program/monthlyPlan/adjustment.html",
		                title: (opt=="edit"?"编辑":"新增")+"节点计划调整申请", width: 1100, height: 700,
		                onload: function () {
		                        var data = {"id": row.id,"state":opt};
		                        if(opt=="edit"){
		                            var data = {"id": row.id,"state":opt};
		                        }else{
		                            var data = {"state":opt};
		                        }
		                        var iframe = this.getIFrameEl();
		                        iframe.contentWindow.view.SetData(data);
		                },
		                
		            });
	        		
	        	}
	        }else {
	            	mini.alert("请选择要调整的计划节点");
	        }
        },
        
//      成果填报
        completeReport: function(){
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.open({
                    url: "/program/monthlyPlan/completeReport.html",
                    title: "成果填报", width: 1200, height: 700,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = {"id": row.id};
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        mini.get("datagrid1").reload();
                    }
                });

            } else {
                alert("请选中一条记录");
            }
        },
        
        
        
        //    进度填报
        recordInfo: function(){
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.open({
                    url: "/program/monthlyPlan/recordInfo.html",
                    title: "进度填报", width: $(window.parent.document).width()-280, height: 700,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = {"id": row.id};
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        mini.get("datagrid1").reload();
                    }
                });

            } else {
                alert("请选中一条记录");
            }
        },
        //    资料套打
        dataPrint: function(){
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.open({
                    url: "/program/monthlyPlan/dataPrint.html",
                    title: "资料套打详情", width: $(window.parent.document).width()-280, height: 700,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = {"id": row.id};
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        mini.get("datagrid1").reload();
                    }
                });

            } else {
                alert("请选中一条记录");
            }
        },
        
        
        //    填报记录
        recordList: function(){
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.open({
                    url: "/program/monthlyPlan/recordList.html",
                    title: "填报记录", width: 1100, height: 700,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = {"id": row.id};
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        mini.get("datagrid1").reload();
                    }
                });

            } else {
                alert("请选中一条记录");
            }
        },
        //    计划详情
        view: function(){
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.open({
                    url: "/program/monthlyPlan/view.html",
                    title: "计划详情", width: 1100, height: 700,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = {"id": row.id};
                        iframe.contentWindow.view.SetData(data);
                    },
                    ondestroy: function (action) {
                        mini.get("datagrid1").reload();
                    }
                });

            } else {
                alert("请选中一条记录");
            }
        },
        //    查询
        search: function () {
            var years = mini.get("year").getValue();
            var mouths = mini.get("month").getValue();
            var allYear = years+'-'+mouths;
            var data = {
                "nodeName": mini.get("nodeNames").getValue(),
                "yearMonth": allYear
            };
            mini.get("datagrid1").load(data);
        },
        //重置
        reset:function(){
            mini.get("year").setValue(new Date().getFullYear());
            var years = mini.get("year").getValue();
            var endMonth = new Date().getMonth()+1;
            mini.get("month").setValue(endMonth);
            mini.get("nodeNames").setValue("");
            mini.get("datagrid1").load()
        },
        //    删除
        remove: function () {
            var row = mini.get("datagrid1").getSelected();
            if (row) {
                mini.confirm("确定删除选中记录？","确定",function (action) {
                    if(action=="ok"){
                        $.ajax({
                            url: "/messageRemind/del",
                            type : "post",
                            data:{"id":row.id},
                            success: function (text) {
                                if (text.state) {
                                    mini.get("datagrid1").reload();
                                } else {
                                    mini.showMessageBox({
                                        showModal: false,
                                        width: 250,
                                        title: "提示",
                                        iconCls: "mini-messagebox-warning",
                                        message: text.message
                                    });

                                }
                            }
                        });
                    }
                });
            } else {
                alert("请选中一条记录");
            }
        },
        SetData: function(data){
            mini.get("datagrid1").load({"state":data.state});
        },
        //打印
        print:function () {
            mini.open({
                url: "/program/monthlyPlan/print.html",
                title: "关键节点计划",
                width: $(window).width(),
                height: $(window).height(),
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var years = mini.get("year").getValue();
                    var mouths = mini.get("month").getValue();
                    var allYear = years+'-'+mouths;
                    var data = {
                        "pageIndex": 0,
                        "pageSize":20,
                        "nodeName": mini.get("nodeNames").getValue(),
                        "yearMonth": allYear
                    };
                    iframe.contentWindow.print.SetData(data);
                },
                ondestroy: function (action) {
                    mini.get("datagrid1").reload();
                }
            });
        },
        //导出
        exportExcel:function () {
        	 if(mini.get("datagrid1").getTotalCount()>0) {
        		 var years = mini.get("year").getValue();
                 var mouths = mini.get("month").getValue();
                 var allYear = years+'-'+mouths;
                 var data = {
                     "nodeName": mini.get("nodeNames").getValue(),
                     "yearMonth": allYear,
                     "pageIndex": 0,
                     "pageSize":500,
                 };
                 var params = $.param(data);
             	
     			//序列化参数  
     		     var url = "/monthlyPlanExecution/exportExcel?"+params; 
     			//导出请求			     
     		   $('<form method="post" action="' + url + '"></form>').appendTo('body').submit().remove();
        	 }else{
                 mini.alert("数据为空,不能导出");
        	 }
		     
		}
    };
    list.init();
</script>
</body>
</html>